<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app"></div>
    <script src="https://unpkg.com/@vue/reactivity@3.0.5/dist/reactivity.global.js"></script>

    <script>
        const { effect, ref } = VueReactivity


        function createRenderer() {
            function patch(n1, n2, container) {

            }
            function render(vnode, container) {
                if (vnode) {
                    // 新node 打补丁
                    patch(container._vnode, vnode, container)
                } else {
                    if (container._vnode) {
                        container.innerHTML = ''
                    }
                }

                // 记录旧的vnode
                container._vnode = vnode
            }

            return {
                render
            }
        }

        const count = ref(1)

        const renderer = createRenderer();

        effect(() => {
            renderer.render(`<h1>${count.value}</h1>`, document.getElementById('app'))
        })

        setInterval(() => {
            count.value = count.value + 1;
        }, 1000)
    </script>
</body>

</html>